<template>
  <div class="box">
    <h2>子组件1</h2>
    <div>哥哥</div>
    <div>
      弟弟给的钱： <span v-if="money">{{ money }}</span>
    </div>
  </div>
</template>
<script setup>
import emmitter from "@/utils/emmiter";
import { ref, onUnmounted } from "vue";
const money = ref(0);
emmitter.on("send-money", (val) => {
  money.value += val;
});
onUnmounted(() => {
  emmitter.off("send-money");
});
</script>
<style lang="less" scoped>
.box {
  background: rgb(200, 221, 162);
}
</style>
